For each of the following questions, type in the given code and record the results as your answer.
I need to be able to clearly see each of the inputs and outputs from the list below. You should be able to cut
and paste your work into a Word document to hand in.
(1 pt each for the first 6 items, then 4 pts for the Python file (last) part = 10 pts
)
- Print statement
>>>print "hello"
>>>print ("hello")
- Addition
>>>a=3
>>>a
>>>b=7
>>>b
>>>a+b
- Data types
>>>c=5.3
>>>c
>>>int(c)
>>>float(c)
- More arithmetic and data types
>>>15/2
>>>15.0/2.0
>>>456 % 10
>>>456 / 10
>>>456.0 / 10.0
>>>2+3
>>>"2"+"3"
>>>r=3
>>>r
>>>print 3.14159*r**2
- Lists with a comment
>>>print ["E", "F", "F"] # a list of strings
>>>print [2, 4, 6, 8] # a list of numbers
- Logic
>>> n=5
>>> n
>>> n==0
>>> n!=0
>>> n==5
- Create a Python file
From the Python shell, select File → New Window.
In that new window, type in two separate print statements of your choice, for example:
the statement to print "Python programming" on one line, and "Is Fun" on another line. Use your own example.
Then, select Run → Run Module. It may prompt you to save the file. If so, give it a name like
"printtest.py", and place it where you can find it, e.g. on your desktop. Watch what happens when you run the
module. Briefly describe what happened, using screen shot(s) (i.e. Alt Print-Screen on a PC), or, a word
description, or both.
Type your name, "CS 110 HW11: Introduction to Python", and the date completed --- at the top of your paper
and upload into Blackboard Learn by the due date. Remember the filenaming convention of
Lastname_Firstname_HW11.docx or something similar.